How to: Debug a macro.
Solution:
Position the insertion point at the beginning of the code to be debugged, run the code with breakpoint set, and step through the code until the problem is found.
1) Select the module sheet that contains the code to be debugged.
2) Position the insertion point at the beginning of the code that may be causing a problem.
3) Select the 'Run' menu and select 'Toggle Breakpoint'. (The first statement is highlighted.)
4) Select the 'Run' menu and select 'Start'.
NOTE: When Visual Basic locates a breakpoint, it stops processing the code and displays the 'Debug' window.
5) Select the 'Run' menu and select 'Step Into' to execute the next statement.
NOTE: Repeat this step until the problem is found. When a problem is found, the 'Macro Error' dialog box appears.
6) Click 'End' in the 'Macro Error' dialog box.
7) Edit the code to fix the problem.